<template>
  <div class="box">
    <div class="left">
      <div class="icon">
        <svg-icon :icon-class="icon" />
      </div>
      <div class="title">{{title}}</div>
    </div>
    <div class="right" v-if="rightMenu">
      <svg-icon
        @mouseenter="leftEnterChange"
        @mouseleave="leftLeaveChange"
        @click="handleToLast"
        :icon-class="leftButton? 'left_arrow' : 'left_arrow_active'"
        class-name="arrow"
      />
      <span style="padding:0 9px;color:rgba(6,27,65,0.45)">|</span>
      <svg-icon
        @mouseenter="rightEnterChange"
        @mouseleave="rightLeaveChange"
        @click="handleToNext"
        :icon-class="rightButton? 'right_arrow' : 'right_arrow_active'"
        class-name="arrow"
      />
    </div>
  </div>
</template>

<script>
export default {
  name: "Platehead",
  props: {
    icon: String,
    title: String,
    rightMenu: Boolean
  },
  data() {
    return {
      rightButton: true,
      leftButton: true,
      currentPage: 1
    };
  },
  methods: {
    leftEnterChange() {
      this.leftButton = false;
    },
    leftLeaveChange() {
      this.leftButton = true;
    },
    rightEnterChange() {
      this.rightButton = false;
    },
    rightLeaveChange() {
      this.rightButton = true;
    },
    handleToLast() {
      if (this.currentPage === 1) {
        return;
      } else {
        this.currentPage--;
      }
      this.$emit("handleToLast", this.currentPage);
    },
    handleToNext() {
      this.currentPage++;
      this.$emit("handleToNext", this.currentPage);
    }
  }
};
</script>

<style lang="scss" scoped>
.box {
  width: 1200px;
  margin: 100px auto 30px auto;
  padding: 24px 0;
  border-top: 1px solid rgba(6, 27, 65, 0.08);
  border-bottom: 1px solid rgba(6, 27, 65, 0.08);
  display: flex;
  justify-content: space-between;
  .left {
    display: flex;
    align-items: center;
    .icon {
      font-size: 34px;
      margin-right: 16px;
      position: relative;
      top: 2px;
    }
    .title {
      height: 23px;
      font-size: 24px;
      font-family: MicrosoftYaHeiSemibold;
      font-weight: 600;
      color: rgba(6, 27, 65, 0.65);
      line-height: 24px;
    }
  }
  .right {
    display: flex;
    align-items: center;
    .arrow {
      font-size: 30px;
      cursor: pointer;
    }
    .arrow:hover {
      color: #92c8ff;
    }
  }
}
</style>